﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 计算器
{
    public partial class Form1 : Form
    {
        public List<Ques> wronglist;
        public bool addcheck;
        public bool subcheck;
        public bool mulcheck;
        public bool divcheck;
        public int addmin;
        public int addmax;
        public int addrmin;
        public int addrmax;
        public int sub1min;
        public int sub1max;
        public int sub2min;
        public int sub2max;
        public int mulmin;
        public int mulmax;
        public int mulrmax;
        public int mulrmin;
        public int div1min;
        public int div1max;
        public int div2min;
        public int div2max;
        public int questionnum;
        public int mytime;
        public int wrong;
        public Form1()
        {
            InitializeComponent();
            Sub1Max.Text = "100";
            Sub1Min.Text = "50";
            Sub2Max.Text = "50";
            Sub2Min.Text = "0";
            AddMin.Text = "0";
            AddMax.Text = "100";
            AddRMin.Text = "0";
            AddRMax.Text = "100";
            MulMax.Text = "20";
            MulMin.Text = "0";
            MulRMin.Text = "0";
            MulRMax.Text = "100";
            Div1Min.Text = "50";
            Div1Max.Text = "100";
            Div2Max.Text = "20";
            Div2Min.Text = "1";

            AddMin.Enabled =AddMax.Enabled =AddRMax.Enabled=AddRMin.Enabled= Sub1Max.Enabled = Sub1Min.Enabled = Sub2Max.Enabled = Sub2Min.Enabled = MulMax.Enabled = MulMin.Enabled=MulRMax.Enabled=MulRMin.Enabled = Div1Max.Enabled = Div1Min.Enabled = Div2Max.Enabled = Div2Min.Enabled = false;
            wrong = 0;
            this.StartPosition = FormStartPosition.CenterScreen;
           // btnRe.Enabled = false;
            wronglist=new List<Ques>();
            addcheck = mulcheck = subcheck = divcheck = false;
            addmin = addmax = sub1max = sub1min = sub2max=addrmax=addrmin=mulrmax=mulrmin = sub2min = sub2max = mulmin = mulmax = div1min = div1max = div2min = div2max = questionnum = mytime = 0;
        }



        private void Form1_Load(object sender, EventArgs e)
        {

          
        }

        private void btnsave_Click(object sender, EventArgs e)
        {
            //if (wrong == 0)
            //    btnRe.Enabled = false;
            //if (wrong > 0)
            //    btnRe.Enabled = true;
            addcheck = AddCheck.Checked;
            subcheck = SubCheck.Checked;
            mulcheck = MulCheck.Checked;
            divcheck = DivCheck.Checked;
            addmin = Convert.ToInt32(AddMin.Text);
            addmax = Convert.ToInt32(AddMax.Text);
            addrmax = Convert.ToInt32(AddRMax.Text);
            addrmin = Convert.ToInt32(AddRMin.Text);
            sub1max = Convert.ToInt32(Sub1Max.Text);
            sub1min = Convert.ToInt32(Sub1Min.Text);
            sub2max = Convert.ToInt32(Sub2Max.Text);
            sub2min = Convert.ToInt32(Sub2Min.Text);
            mulmin = Convert.ToInt32(MulMin.Text);
            mulmax = Convert.ToInt32(MulMax.Text);
            mulrmax = Convert.ToInt32(MulRMax.Text);
            mulrmin = Convert.ToInt32(MulRMin.Text);
            div1min = Convert.ToInt32(Div1Min.Text);
            div1max = Convert.ToInt32(Div1Max.Text);
            div2min = Convert.ToInt32(Div2Min.Text);
            div2max = Convert.ToInt32(Div2Max.Text);
            questionnum = Convert.ToInt32(question.Text);
            mytime = Convert.ToInt32(countime.Text);
            Q q = new Q();
            q.father = this;
            q.ShowDialog();

    }

        private void btnRe_Click(object sender, EventArgs e)
        {
            if (wrong > 0)
            {
                Re re = new Re();
                re.father = this;
                re.ShowDialog();
            }
            else
            {
                MessageBox.Show("还没有错题记录");
            }
        }

        private void AddCheck_CheckedChanged(object sender, EventArgs e)
        {
            if (AddCheck.Checked == true)
            {
                AddMin.Enabled = AddMax.Enabled = AddRMax.Enabled = AddRMin.Enabled = true;

             
            }
            else
            {
                AddMin.Enabled = AddMax.Enabled = AddRMax.Enabled = AddRMin.Enabled = false;
            }


        }

        private void SubCheck_CheckedChanged(object sender, EventArgs e)
        {
            if ( SubCheck.Checked == true)
            {
                Sub1Max.Enabled = Sub1Min.Enabled = Sub2Max.Enabled = Sub2Min.Enabled = true;
              
            }
            else
            {
                Sub1Max.Enabled = Sub1Min.Enabled = Sub2Max.Enabled = Sub2Min.Enabled = false;
            }


        }

        private void MulCheck_CheckedChanged(object sender, EventArgs e)
        {
            if (MulCheck.Checked== true)
            {
                MulMax.Enabled = MulMin.Enabled = MulRMax.Enabled = MulRMin.Enabled = true;


            }
            else
            {
                MulMax.Enabled = MulMin.Enabled = MulRMax.Enabled = MulRMin.Enabled = false;
            }

        }

        private void DivCheck_CheckedChanged(object sender, EventArgs e)
        {
            if (DivCheck.Checked == true)
            {
                Div1Max.Enabled = Div1Min.Enabled = Div2Max.Enabled = Div2Min.Enabled = true;

            }
            else
            {
                Div1Max.Enabled = Div1Min.Enabled = Div2Max.Enabled = Div2Min.Enabled = false;
            }
        }


    }
}
